import requests
from flask import Flask, request

app = Flask(__name__)


@app.route('/clock')
def clock():
    device_id = request.args.get("device_id")
    session_id = request.args.get("session_id")
    signature_ = request.args.get("signature_")
    print(signature_)
    url = 'https://www.guangeryi.com/admin2/attendance/app/clock'
    headers = {'accept': 'application/json, text/plain, */*',
               'x-requested-with': 'XMLHttpRequest',
               'jsessionid': session_id,
               'Content-Type': 'application/json;charset=UTF-8',
               'Connection': 'Keep-Alive',
               'User-Agent': 'okhttp/3.6.0'
               }

    # signature_ = js_execjs.call('get_sign')
    data = '{"deviceId":"' + device_id + '","fdLocation":"","signature":"' + signature_ + '"}'

    r = requests.post(url, data, headers=headers)
    return r.text


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=5888)
